package com.tedu.lingmaagent.controller;

import com.tedu.lingmaagent.assistant.Assistant;
import com.tedu.lingmaagent.domain.FormMessage;
import dev.langchain4j.community.model.dashscope.QwenStreamingChatModel;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;


@Tag(name="灵码挂号")
@RestController
@RequestMapping("/lingma")
public class LingMaController {


    @Autowired
    private Assistant assistant;
    //API接口的一个操作
    //RequestBody 请求必须以JSON字符串请求，然后将请求的数据封装到FormMessage对象中

    @Operation(summary = "聊天")
    @PostMapping(value = "/chat",produces="text/stream;charset=utf-8")

    public Flux<String> chat(@RequestBody FormMessage formMessage){
        return assistant.chat(formMessage.getMemoryId(), formMessage.getMessage());
    }
}
